package cn.edu.sjtu.se.peakfactory.dao.bean;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "PEAK_FACTORY_FORMULA_TABLE")
public class Formula {
	private Long id;
	private String description;
	private String formula;

	private Coupon coupon;
	private List<Element> elements;

	private Integer status;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "FORMULA_DESCRIPTION")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "FORMULA_DETAIL")
	public String getFormula() {
		return formula;
	}

	public void setFormula(String formula) {
		this.formula = formula;
	}

	@ManyToOne
	@JoinColumn(name = "COUPON_ID")
	public Coupon getCoupon() {
		return coupon;
	}

	public void setCoupon(Coupon coupon) {
		this.coupon = coupon;
	}

	@ManyToMany
	@JoinTable(name = "PEAK_FACTORY_FORMULA_TABLE", joinColumns = @JoinColumn(name = "FORMULA_ID"), inverseJoinColumns = @JoinColumn(name = "ELEMENT_ID"))
	public List<Element> getElements() {
		return elements;
	}

	public void setElements(List<Element> elements) {
		this.elements = elements;
	}

	@Column(name = "FORMULA_STATUS")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

}
